<?php
/**
 * UserValidate.php
 * @author zohnの梦
 * @email  1171672036@qq.com
 * @date   2021/1/8
 */

namespace app\api\validate;


use think\Validate;

class UserValidate extends Validate
{
    protected $rule = [
        'id'       => ['require', 'number'],
        'ids'      => ['require', 'array'],
        'username' => ['require', 'min:4', 'unique:user'],
        'password' => ['require', 'max:32']
    ];

    protected $message = [
        'id.require'       => '参数不能为空',
        'id.number'        => '参数类型错误',
        'ids.require'      => '参数不能为空',
        'ids.array'        => '参数类型错误',
        'username.require' => '用户名不能为空',
        'username.min'     => '用户名最少4位',
        'username.unique'  => '该用户已存在',
        'password.require' => '密码不能为空',
        'password.max'     => '密码最大32位'
    ];

    protected $scene = [
        'detail' => ['id'],
        'create' => ['username', 'password'],
        'update' => ['id', 'username'],
        'delete' => ['id']
    ];
}